package i7bac.menu;

import java.awt.Event;
import java.awt.Font;
import java.awt.event.KeyEvent;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.KeyStroke;

@SuppressWarnings("serial")
public class MenuBar extends JMenuBar {

	// File Menu
	public JMenuItem newSet, openFile, saveAs, exit;
	// Edit Menu
	public JMenuItem cut, copy, paste, selectAll;

	public MenuBar(Font font) {
		super();
		/*
		 * FILE MENU
		 * 		New Set (Ctrl-N): Create a new set from zero
		 * 		Open File (Ctrl-O): Open a file containing an existing set
		 * 		Save As (Ctrl-S): Save the current set in a file
		 * 		Recent Files: Up to 4 recent files are shown for faster set load
		 * 		Exit: Close the application
		 */
		JMenu file = new JMenu("File");
		file.setFont(font);
		file.setMnemonic(KeyEvent.VK_F);

		newSet = new JMenuItem("New Set", 'n');
		newSet.setFont(font);
		newSet.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, Event.CTRL_MASK));
		file.add(newSet);

		openFile = new JMenuItem("Open File...", 'o');
		openFile.setFont(font);
		openFile.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, Event.CTRL_MASK));
		file.add(openFile);

		file.addSeparator();

		saveAs = new JMenuItem("Save As...", 's');
		saveAs.setFont(font);
		saveAs.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, Event.CTRL_MASK));
		file.add(saveAs);

		file.addSeparator();

		exit = new JMenuItem("Exit", 'x');
		exit.setFont(font);
		file.add(exit);

		this.add(file);

		/*
		 * EDIT MENU
		 * 		Cut (Ctrl-X): Cut the container selected
		 * 		Copy (Ctrl-C): Copy the container selected
		 * 		Paste (Ctrl-V): Paste a previously copied container
		 * 		Select All (Ctrl-A): Select all the container
		 */
		JMenu edit = new JMenu("Edit");
		edit.setFont(font);
		edit.setMnemonic(KeyEvent.VK_E);

		cut = new JMenuItem("Cut", 't');
		cut.setFont(font);
		cut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.CTRL_MASK));
		edit.add(cut);

		copy = new JMenuItem("Copy", 'c');
		copy.setFont(font);
		copy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, Event.CTRL_MASK));
		edit.add(copy);

		paste = new JMenuItem("Paste", 'p');
		paste.setFont(font);
		paste.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, Event.CTRL_MASK));
		edit.add(paste);

		edit.addSeparator();

		selectAll = new JMenuItem("Select All", 'a');
		selectAll.setFont(font);
		selectAll.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, Event.CTRL_MASK));
		edit.add(selectAll);

		this.add(edit);
	}
}
